package com.asw.springboot.common.Adapter;

import com.asw.springboot.common.interceptor.MyInterceptor1;
import com.asw.springboot.common.interceptor.MyInterceptor2;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by hxq on 2017/5/17.
 * 添加请求拦截器,相当于xml中的拦截器适配
 */
@Configuration
public class WebPathAppConfigurer extends WebMvcConfigurerAdapter {
    // 多个拦截器组成一个拦截器链
    // addPathPatterns 用于添加拦截规则
    // excludePathPatterns 用户排除拦截
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptor1()).addPathPatterns("/api/**");
        registry.addInterceptor(new MyInterceptor2()).addPathPatterns("/api/**").excludePathPatterns("/findCityById");
        super.addInterceptors(registry);
    }
}
